{extend name="layout/layout" /}

{block name="pagecss"}
<link href="__STATIC__/plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css" />
<link href="__STATIC__/plugins/ueditor/ueditor.css" rel="stylesheet" type="text/css" />
<style>
    #upload-image img {
        width: 100px;
        height: 100px;
        cursor: pointer;
        border: 1px solid #ccc;
    }
    #edui1_imagescale{display:none !important;}  /*点击上传的图片后出现的拉伸边框*/
    .edui-editor-bottomContainer{display: none;}
</style>
{/block}

{block name="content"}
<div class="row">
    <div class="col-md-12">
        <div class="portlet light">
            <div class="portlet-title">
                <div class="caption">
                    <i class="icon-share font-dark"></i>
                    <span class="caption-subject font-dark bold uppercase"> 编辑</span>
                </div>
                <div class="actions">
                    <a class="btn btn-circle btn-icon-only btn-default fullscreen" href="javascript:;" data-original-title="" title=""> </a>
                </div>
            </div>
            <div class="portlet-body">
                <form action="{:url('admin/'.strtolower($model).'/editpost')}" class="form-horizontal validation-form" method="post" enctype="multipart/form-data">
                    {:token()}
                    <div class="form-body">
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        所在地
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-9">
                                        <p class="form-control-static"> {$area} </p>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        产品名称
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-9">
                                        <input type="text" class="form-control" id="title" data-required="1" maxlength="30" placeholder="" name="title" value="{$info.title}" >
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        分类
                                    </label>
                                    <div class="col-md-3">
                                        <select id="type" name="typeId" class="form-control"></select>
                                    </div>
                                    <div class="col-md-3">
                                        <select id="varietie" name="varietieId" class="form-control"></select>
                                    </div>
                                    <input type="hidden" class="form-control type" name="type" value="{$info.typeId}">
                                    <input type="hidden" class="form-control varietie" name="varietie" value="{$info.varietieId}">
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        封面图
                                    </label>
                                    <div class="col-md-9">
                                        <div id="upload-image">
                                            <span id="upload-btn" data-multi="false">
                                                <input type="hidden" class="form-control" id="coverImg" data-required="1" name="coverImg" value="{$info.imgUrl}">
                                                <img src="{$info.imgUrl|default='__STATIC__/admin/img/default.png'}" alt="图片上传" style="width: 100px;height: 100px;" />
                                            </span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        产品图
                                    </label>
                                    <div class="col-md-9">
                                        <div id="cover-image">
                                            {foreach name="imagesList" item="images"}
                                            <span class="multi-image">
                                                <input type="hidden" name="imgIds" value="{$images.id}">
                                                <input type="hidden" name="imgUrl" value="{$images.imgUrl}">
                                                <img class="exist-image" src="{$images.imgUrl}" alt="">
                                                <img class="del" src="__STATIC__/pages/image/del.png" alt="">
                                            </span>
                                            {/foreach}
                                            <span id="upload-cover-btn" data-multi="true" data-field="imgUrl">
                                                <!--<input type="hidden" class="form-control" id="imgUrl" data-required="1" name="imgUrl" value="">-->
                                                <img src="__STATIC__/admin/img/default.png" alt="图片上传" style="width: 100px;height: 100px;" />
                                            </span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        产品售价（元）
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-9">
                                        <div class="row">
                                            <div class="col-xs-8">
                                                <input type="text" class="form-control" id="price" data-required="1" name="price" value="{$info.price / 100}" >
                                            </div>
                                            <div class="col-xs-1">
                                                <label class="control-label pull-right">单位</label>
                                            </div>
                                            <div class="col-xs-3">
                                                <select class="form-control" name="unit">
                                                    {foreach name="unitList" item="unit" key="unitkey"}
                                                    <option value="{$unitkey}" {if condition="($info['unit'] == show_product_unit($unitkey))"}selected="selected"{/if}>{$unit}</option>
                                                    {/foreach}
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        总数量
                                    </label>
                                    <div class="col-md-9">
                                        <div class="row">
                                            <div class="col-xs-8">
                                                <input type="number" class="form-control" id="stock" name="stock" value="{$info.stock}">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        起购数量
                                    </label>
                                    <div class="col-md-9">
                                        <div class="row">
                                            <div class="col-xs-8">
                                                <input type="number" class="form-control" id="minBuyNum" data-required="1" name="minBuyNum" value="{$info.minBuyNum}">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        预售期
                                    </label>
                                    <div class="col-md-9">
                                        <div class="row">
                                            <div class="col-md-4">
                                                <input type="text" class="form-control" id="startTime" name="preStartTime" value="{$info.preStartTime}" placeholder="开始时间" autocomplete="off" readonly>
                                            </div>
                                            <div class="col-md-4">
                                                <input type="text" class="form-control" id="endTime" name="preEndTime" value="{$info.preEndTime}" placeholder="结束时间" autocomplete="off" readonly>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        预计发货日期
                                    </label>
                                    <div class="col-md-9">
                                        <div class="row">
                                            <div class="col-xs-8">
                                                <input type="text" class="form-control" id="preDeliverDate" name="preDeliverDate" value="{$info.preDeliverDate}" autocomplete="off" readonly>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        产品规格
                                    </label>
                                    <div class="col-md-9">
                                        <label class="control-label add-spec" style="color: #00a65a; cursor: pointer;">添加规格</label>
                                        <div class="list-group"></div>
                                        <div id="specJson">
                                            {php}$specList = json_decode($info['specJson'], true);{/php}
                                            {foreach name="specList" item="specs"}
                                            <div class="list-group">
                                                <div class="row">
                                                    <div class="col-xs-4">
                                                        <input type="text" class="form-control spec_format" name="spec_format[]" placeholder="规格名称 如：单个重" value="{$specs.spec_format}">
                                                    </div>
                                                    <div class="col-xs-4">
                                                        <input type="text" class="form-control spec_value" name="spec_value[]" placeholder="规格说明 如：4-5两" value="{$specs.spec_value}">
                                                    </div>
                                                    <div class="col-xs-2">
                                                        <label class="control-label del-spec" style="color: red; cursor: pointer;">删除</label>
                                                    </div>
                                                </div>
                                            </div>
                                            {/foreach}
                                            {empty name="specList"}
                                            <div class="list-group">
                                                <div class="row">
                                                    <div class="col-xs-4">
                                                        <input type="text" class="form-control spec_format" name="spec_format[]" placeholder="规格名称 如：单个重" value="">
                                                    </div>
                                                    <div class="col-xs-4">
                                                        <input type="text" class="form-control spec_value" name="spec_value[]" placeholder="规格说明 如：4-5两" value="">
                                                    </div>
                                                    <div class="col-xs-2">
                                                        <label class="control-label del-spec" style="color: red; cursor: pointer;">删除</label>
                                                    </div>
                                                </div>
                                            </div>
                                            {/empty}
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        订购电话
                                    </label>
                                    <div class="col-md-9">
                                        <input type="text" maxlength="13" placeholder="订购电话" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^0-9]/g,'')}else{this.value=this.value.replace(/[^0-9-]/g,'')}" class="form-control"  name="phone" value="{$info.phone}">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        产品介绍
                                    </label>
                                    <div class="col-md-9">
                                        <script id="container" name="description" type="text/plain"></script>
                                        <div id="pro_txt" class="hidden">{$info.description}</div>
                                        <div id="btn-uploader1">
                                            <a id="pickfiles1" href="javascript:void 0;"></a>
                                        </div>
                                        <a id="pickfilesforarticleRadio" href="javascript:;"></a>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <input type="hidden" name="id" value="{$info.id}">
                        <input type="hidden" name="style" value="2">

                        <hr />
                        <div class="row">
                            <div class="form-actions">
                                <div class="col-md-offset-2 col-md-10">
                                    <button type="button" id="form-submit" class="btn blue save-btn">
                                        保存 <i class="fa fa-floppy-o"></i>
                                    </button>
                                    <button type="button" class="btn default" onclick="history.go(-1);">
                                        返回 <i class="fa fa-mail-forward"></i>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<input type="hidden" class="token_url" value="{:url('admin/Image/token')}">
<input type="hidden" class="record_url" value="{:url('admin/Image/record')}">
<input type="hidden" class="delimage_url" value="{:url('admin/Image/delete')}">
<input type="hidden" class="save_url" value="{:url('admin/'.strtolower($model).'/editpost')}">
<input type="hidden" class="redirect_url" value="{:url('admin/presale/index')}">

<input type="hidden" class="getcategory_url" value="{:url('admin/product/getcategory')}">
{/block}

{block name="pagescript"}
<script src="__STATIC__/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
<script src="__STATIC__/plugins/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" type="text/javascript"></script>
<script type="text/javascript" src="__STATIC__/plugins/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/plugins/ueditor/ueditor.all.js"></script>
<script src="__STATIC__/admin/js/qiniu/plupload.full.min.js" type="text/javascript"></script>
<script src="__STATIC__/admin/js/qiniu/qiniu.js" type="text/javascript"></script>
<script src="__STATIC__/admin/js/qiniu/custom.js" type="text/javascript"></script>
<script src="__STATIC__/admin/js/qiniu/qiniuConfig.js" type="text/javascript"></script>

<script src="__STATIC__/admin/pages/js/uploadfile.js" type="text/javascript"></script>
<script src="__STATIC__/admin/pages/js/ueditor.js" type="text/javascript"></script>
<script src="__STATIC__/admin/pages/js/presale.js" type="text/javascript"></script>
{/block}